package com.plant.tool;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;


public class ListMapSort {
	@SuppressWarnings("rawtypes")
	public static void Sort(List<Map<String, Object>> data){//搜索问答 根据评论数排序
		Collections.sort(data, new Comparator<Map>() {
			public int compare(Map o1, Map o2) {
				Integer a=Integer.parseInt(o1.get("count_like").toString());
				Integer b=Integer.parseInt(o2.get("count_like").toString());
				return b.compareTo(a);
			}
		});
	}
	
	public static List<Map<String, Object>> ListSomeInf(List<Map<String, Object>> data){//搜索问答 根据评论数排序20条数据
		List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
		  for(int i=0;i<19;i++){
		   newList.add(data.get(i));
		  }
		  newList.add(data.get(data.size()-1));
		  return newList;
	}
	
	public static List<Map<String, Object>> ListThreeInf(List<Map<String, Object>> data){//搜索问答 根据评论数排序20条数据
		List<Map<String, Object>> newList = new ArrayList<Map<String, Object>>();
		for(int i=0;i<2;i++){
			newList.add(data.get(i));
		}
		newList.add(data.get(data.size()-1));
		return newList;
	}
	
	
	
	
}
